#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

int firstUniqChar(string s) {
    vector<int> num(122-97+1, 0);
    for(int i = 0; i < s.size(); i++){
        num[int(s[i])-97]++;
    }
    for(int i = 0; i < s.size(); i++){
        if(num[int(s[i])-97] == 1){ return i; }
    }
    return -1;
}

int main(){
    string s = "loveleetcode";
    int ret = firstUniqChar(s);
    cout << ret << endl;
    return 0;
}